<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="demo" index1="1" class="nav">123123</div>
    <script>
        let div = document.querySelector('div');
        console.log(typeof div);
        console.dir(div);

        // 1.获取对象的自带属性
        console.log(div.id);
        console.log(div.class);
        console.log(div.index1);

        // 2.设置获取自定义属性(相当于给对象动态的添加属性)
        console.log(div.getAttribute('class'));
        console.log(div.getAttribute('index1'));
        div.setAttribute('index2','coco');
        console.log(div.getAttribute('index2'));

        // 3.移除属性
        div.removeAttribute('class');
    </script>
</body>
</html>